<template>
	<view class="container">
		<view class="list-container" v-if="contractList">
			<view class="list-item">
				<view class="item" v-for="(item,index) in contractList" :key="index" @click="goDetail(item)">
					<view class="left">
						<text>
							合同编号：<text class="content">{{item.contractId}}</text>
						</text>
						<text>
							签署时间：<text class="content">{{item.signTime}}</text>
						</text>
						<text>
							签署人：<text class="content">{{item.signName}}</text>
						</text>
					</view>
					<view class="right">
						<u--image width="110rpx" height="110rpx" :src="item.expireStatus == 0 ? signedImage:passDateImage"></u--image>
					</view>
				</view>
			</view>
		</view>
		<view style="padding: 40rpx;" v-if="contractList.length == 0">
			<u--text  bold align="center" type="info" text="没有数据"></u--text>
		</view>
	</view>
</template>

<script>
	import {findUserContract} from "@/api/api.js"
	export default {
		data() {
			return {
				signedImage:require("@/static/signed.png"),
				passDateImage:require("@/static/passDate.png"),
				contractList:[],
			};
		},
		onPullDownRefresh() {
			this.getContractList()
		},
		onShow() {
			this.getContractList()
		},
		methods:{
			async getContractList(){
				uni.showLoading({
					mask:true,
				})
				const res = await findUserContract()
				try{
					if(res?.data.code == 200){
						console.log(res);
						this.contractList = res?.data?.data || []
						uni.hideLoading()
					}else{
						uni.$u.toast(res.data.msg)
						uni.hideLoading()
					}
				}catch(e){
					uni.hideLoading()
					uni.$u.toast(e)
					throw e
				}
			},
			goDetail(item){
				uni.navigateTo({
					url:"/pages/user/contractDetail?tenancyId="+item.tenancyId
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
.container{
	.list-container{
		.list-item{
			padding: 20rpx;
			.item{
				background-color: #FFFFFF;
				height:208rpx;
				padding: 28rpx;
				display: flex;
				align-items: center;
				box-shadow: 2rpx 2rpx 6rpx 2rpx #ececec;
				margin-bottom: 20rpx;
				.left{
					width: 70%;
					height: 100%;
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					font-size: 30rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					color: #8C8C8C;
					line-height: 32rpx;
					white-space: nowrap;
					.content{
						color: #000000;
						font-size: 28rpx;
					}
				}
				.right{
					width: 30%;
					display: flex;
					justify-content: center;
				}
			}
		}
	}
}
</style>
